class Rudoku::CandidateSelection
  attr_reader :candidate_selector, :field, :candidate, :params
  
  def initialize(candidate_selector, field, candidate, params)
    @candidate_selector, @field, @candidate, @params = candidate_selector, field, candidate, params
  end
  
  def reason # get a nicely formatted reason message for this particular elimination
    return nil if @candidate_selector.reason.nil?
    
    @candidate_selector.reason.gsub(/\:[a-zA-Z0-9]*/) do |match|
      match.gsub!(":", "")
      
      case match
      when "candidate"
        @candidate
      when "field"
        @field.position
      else
        @params[match.to_sym]
      end
    end
  end
end

